<template>
  <div class="movies">
    <div class="container">
      <div class="filter-bar">
        <div class="filter-item">
          <span class="label">类型：</span>
          <el-radio-group v-model="filters.type" size="small">
            <el-radio-button label="all">全部</el-radio-button>
            <el-radio-button label="action">动作</el-radio-button>
            <el-radio-button label="comedy">喜剧</el-radio-button>
            <el-radio-button label="romance">爱情</el-radio-button>
            <el-radio-button label="sci-fi">科幻</el-radio-button>
            <el-radio-button label="animation">动画</el-radio-button>
          </el-radio-group>
        </div>
        <div class="filter-item">
          <span class="label">区域：</span>
          <el-radio-group v-model="filters.region" size="small">
            <el-radio-button label="all">全部</el-radio-button>
            <el-radio-button label="cn">中国大陆</el-radio-button>
            <el-radio-button label="us">美国</el-radio-button>
            <el-radio-button label="kr">韩国</el-radio-button>
            <el-radio-button label="jp">日本</el-radio-button>
          </el-radio-group>
        </div>
        <div class="filter-item">
          <span class="label">特色：</span>
          <el-radio-group v-model="filters.feature" size="small">
            <el-radio-button label="all">全部</el-radio-button>
            <el-radio-button label="imax">IMAX</el-radio-button>
            <el-radio-button label="3d">3D</el-radio-button>
            <el-radio-button label="dolby">杜比</el-radio-button>
          </el-radio-group>
        </div>
      </div>

      <div class="movie-list">
        <el-tabs v-model="activeTab" type="border-card">
          <el-tab-pane label="正在热映" name="now">
            <el-row :gutter="20">
              <el-col :xs="12" :sm="8" :md="6" v-for="movie in movies" :key="movie.id">
                <el-card class="movie-card mb-20" :body-style="{ padding: '0px' }">
                  <div class="movie-poster">
                    <img :src="movie.poster" :alt="movie.title">
                    <div class="movie-score" v-if="movie.score">
                      <span class="score">{{ movie.score }}</span>
                    </div>
                  </div>
                  <div class="movie-info">
                    <h3>{{ movie.title }}</h3>
                    <p class="want" v-if="!movie.score">
                      <span class="want-count">{{ movie.wantCount }}人想看</span>
                    </p>
                    <el-button type="primary" @click="goToDetail(movie.id)">
                      {{ movie.score ? '购票' : '预售' }}
                    </el-button>
                  </div>
                </el-card>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="即将上映" name="coming">
            <el-row :gutter="20">
              <el-col :xs="12" :sm="8" :md="6" v-for="movie in comingMovies" :key="movie.id">
                <el-card class="movie-card mb-20" :body-style="{ padding: '0px' }">
                  <div class="movie-poster">
                    <img :src="movie.poster" :alt="movie.title">
                    <div class="release-date">{{ movie.releaseDate }}</div>
                  </div>
                  <div class="movie-info">
                    <h3>{{ movie.title }}</h3>
                    <p class="want">
                      <span class="want-count">{{ movie.wantCount }}人想看</span>
                    </p>
                    <el-button type="danger" @click="handleWantWatch(movie.id)">
                      想看
                    </el-button>
                  </div>
                </el-card>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Movies',
  data() {
    return {
      activeTab: 'now',
      filters: {
        type: 'all',
        region: 'all',
        feature: 'all'
      },
      movies: [
        {
          id: 1,
          title: '满江红',
          poster: require('@/assets/images/满江红.webp'),
          score: 9.5
        },
        {
          id: 2,
          title: '流浪地球2',
          poster: require('@/assets/images/流浪地球2.webp'),
          score: 9.6
        },
        {
          id: 3,
          title: '阿凡达-水之道',
          poster: require('@/assets/images/阿凡达-水之道.webp'),
          score: 8.9
        },
        {
          id: 4,
          title: '八角笼中',
          poster: require('@/assets/images/八角笼中.jpg'),
          score: 9.0
        },
      ],
      comingMovies: [
        {
          id: 3,
          title: '即将上映1',
          poster: require('@/assets/images/消失的她.webp'),
          releaseDate: '3月28日',
          wantCount: 23456
        },
        {
          id: 4,
          title: '即将上映2',
          poster: require('@/assets/images/长安三万里.webp'),
          releaseDate: '4月1日',
          wantCount: 12345
        }
      ]
    }
  },

  methods: {
    goToDetail(id) {
      this.$router.push(`/movie/${id}`)
    },
    handleWantWatch(id) {
      // 处理想看逻辑
      this.$message.success('已标记为想看')
    }
  }
}
</script>

<style scoped>
.filter-bar {
  background: #fff;
  padding: 25px;
  margin-bottom: 30px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.filter-item {
  margin-bottom: 20px;
}

.filter-item:last-child {
  margin-bottom: 0;
}

.label {
  color: #333;
  font-weight: 500;
  margin-right: 15px;
}

.movie-card {
  margin-bottom: 20px;
  transition: all 0.3s;
  border: none;
  border-radius: 8px;
  overflow: hidden;
}

.movie-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(43,134,197,0.15);
}

.movie-poster {
  height: 400px;
  overflow: hidden;
  position: relative;
}

.movie-poster::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
}

.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-score {
  position: absolute;
  right: 10px;
  top: 10px;
  background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
  padding: 8px 12px;
  border-radius: 20px;
  color: #fff;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(255,165,0,0.3);
}

.score {
  font-size: 20px;
  font-weight: bold;
}

.release-date {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(0, 0, 0, 0.6);
  padding: 5px 10px;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
}

.movie-info {
  padding: 20px;
  background: #fff;
}

.movie-info h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.want {
  margin: 12px 0;
  color: #2b86c5;
  font-size: 15px;
}

.want-count {
  font-weight: 600;
  background: linear-gradient(135deg, #2b86c5 0%, #1a5f8d 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.el-button {
  width: 100%;
  margin-top: 15px;
  border-radius: 25px;
  font-size: 16px;
  padding: 12px 20px;
  transition: all 0.3s ease;
}

.el-button--primary {
  background: linear-gradient(135deg, #2b86c5 0%, #1a5f8d 100%);
  border: none;
}

.el-button--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(43,134,197,0.3);
}

.el-button--danger {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5253 100%);
  border: none;
}

.el-button--danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(238,82,83,0.3);
}

.el-tabs--border-card {
  box-shadow: none;
}

.el-tabs__nav {
  display: flex;
}

.el-tabs__item {
  flex: 1;
  text-align: center;
}

.el-radio-button__inner {
  transition: all 0.3s ease;
}

.el-radio-button__orig-radio:checked + .el-radio-button__inner {
  background: linear-gradient(135deg, #2b86c5 0%, #1a5f8d 100%);
  border-color: #1a5f8d;
  box-shadow: 0 2px 8px rgba(43,134,197,0.3);
}
</style> 